<%@ page import="org.icress.fusion.moc.Tc" %>
<%@ page import="org.icress.fusion.moc.Tb" %>
<%@ page import="org.apache.shiro.subject.Subject" %>
<%@ page import="org.apache.shiro.SecurityUtils" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <g:set var="entityName" value="${message(code: 'moc.tc.label', default: 'Tc')}" />
    <title><g:message code="default.create.label" args="[entityName]" /></title>
</head>
<body>
    <g:set var="subject" scope="page" ><shiro:principal/></g:set>
	<g:set var="tb_id" scope="page" >${(tcInstance?.tb?.id==null)?params['tb_id']:tcInstance?.tb?.id}</g:set>
    <div class="body">
        <h1><g:message code="default.create.label" args="[entityName]" /></h1>
        <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
        </g:if>
        <div class="dialog">
        	<g:set var="tbInstance" value="${org.icress.fusion.moc.Tb.get(tb_id.toLong())}" scope="page" />
            <g:render template="/moc/tb/showTemplate" model="[tbInstance:tbInstance]" />
        </div>
        <g:hasErrors bean="${tcInstance}">
        <div class="errors">
            <g:renderErrors bean="${tcInstance}" as="list" />
        </div>
        </g:hasErrors>
        <g:form action="save" >
            <div class="dialog">
				<g:render template="/moc/tc/editTemplate"  model="[tcInstance:tcInstance]"/>
           	</div>
			<div style="display:none">
				<g:select name="createdBy.id" from="${org.icress.fusion.shiro.User.findByUsername(subject)}" optionKey="id" optionValue="username" value="${tcInstance?.createdBy?.id}"  />
				<g:select name="lastModifiedBy.id" from="${org.icress.fusion.shiro.User.findByUsername(subject)}" optionKey="id" optionValue="username" value="${tcInstance?.lastModifiedBy?.id}"  />
				<g:select name="owner.id" from="${org.icress.fusion.shiro.User.findByUsername(subject)}" optionKey="id" optionValue="username" value="${tcInstance?.owner?.id}"  />
			</div>                
			<div class="buttons">
				<shiro:hasPermission permission="tc:create">
			    	<span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}"/></span>
			    </shiro:hasPermission>
			</div>
        </g:form>
    </div>
</body>
</html>
